package com.example.vv.service;

import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
import com.google.common.cache.LoadingCache;
import com.google.common.collect.Lists;
import java.util.List;
import org.springframework.lang.NonNull;

/**
 * 描述：// TODO
 *
 * @author w.dehai.2024/7/24.23:55
 */
public class S {
    public static void main(String[] args) throws Exception {

        LoadingCache<String, List<String>> stringListLoadingCache = notExchangeAreaCache();
        List<String> a = stringListLoadingCache.get("a");
        List<String> b = stringListLoadingCache.get("b");
        System.err.println("end");

        List<String> result = stringListLoadingCache.get("x");
        System.err.println(result);
    }

    public static LoadingCache<String, List<String>> notExchangeAreaCache() {
        return CacheBuilder.newBuilder().concurrencyLevel(1).build(new CacheLoader<String, List<String>>() {
            @Override
            public List<String> load(@NonNull String notExchangeAreaKey) {
                System.err.println(notExchangeAreaKey);
                return Lists.newArrayList("1", "2");
            }
        });
    }
}
